package cn.yunhe.util;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
 * 
 * @author Administrator
 *
 */
public class BaseAction extends ActionSupport{
    //解耦的方式
	/**
	 * @return
	 */
	public Map<String,Object> getMapRequest(){
		return (Map)ActionContext.getContext().get("request");
	}
	public Map<String,Object> getMapSession(){
		return ActionContext.getContext().getSession();
	}
	//耦合的方式
	/**
	 * @return
	 */
	public HttpSession getSession(){
		 return ServletActionContext.getRequest().getSession();
	}
	public HttpServletRequest getRequest(){
		return ServletActionContext.getRequest();
	}
	public HttpServletResponse getResponse(){
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/html;charset=UTF-8");
		return response;
	}
	
}
